<template>
	<view class="demo-page">
		<view class="content">
			<view class="button" @click="toVerify">开始人脸识别</view>
			<view class="upload" @click="toUploadImage">上传图片</view>
			<view v-if="showTitle">{{title}}</view>
			<view></view>
		</view>
	</view>
</template>

<script>
import { wechatMiniFaceDetect, wechatMiniChooseImage } from '@/utils/wechatmini-js'
export default {
	data() {
		return {
			wechatMiniChooseImageCallBackFunBatchSeq: null,
			title: '测试',
			showTitle: false
		}
	},
	onLoad() {
		console.log('demo onLoad')
		window.onblur = () => {
			console.log('onblur')
		}
		window.onfocus = () => {
			console.log('onfocus', this.wechatMiniChooseImageCallBackFunBatchSeq)
			if(this.wechatMiniChooseImageCallBackFunBatchSeq) {
				console.log('this.wechatMiniChooseImageCallBackFunBatchSeq', this.wechatMiniChooseImageCallBackFunBatchSeq)
				this.showTitle = true
				this.title = this.wechatMiniChooseImageCallBackFunBatchSeq
				this.wechatMiniChooseImageCallBackFunBatchSeq = null
			} else {
				this.showTitle = false
			}
		}
	},
	onShow() {
		console.log('demo onShow')
	},
	methods: {
		toVerify() {
			wechatMiniFaceDetect()
		},
		toUploadImage() {
			this.wechatMiniChooseImageCallBackFunBatchSeq = '345666666'
			this.showTitle = false
			wechatMiniChooseImage({}, this)
		}
	}
}
</script>

<style lang="scss" scoped src="./index.scss">
</style>